import request from '@/utils/request'

// 查询所有的商品
export const getAllGoods = () => {
  return request({
    url: 'goodLists'
  })
}

// 根据page和limit 查询当前页商品
export const getAllGoodList = (page, limit) => {
  return request({
    url: `goodLists?_page=${page}&_limit=${limit}`
  })
}

// 根据关键字 查询切换页码和页码数量时的 页面商品
export const getAllGoodListByTag = params => {
  return request({
    url: `goodLists`,
    params
  })
}

// 获取一级分类
export const getGoodCategorys = () => {
  return request({
    url: `goodCategorys`
  })
}

// 获取二级分类 根据一级
export const getSubGoodCategorys = params => {
  return request({
    url: `subGoodCategorys`,
    params
  })
}

// 下架商品
export const soiloutGood = data => {
  return request({
    url: `goodLists/${data.id}`,
    method: 'PUT',
    data
  })
}

// 删除商品
export const delGoodById = id => {
  return request({
    url: `goodLists/${id}`,
    method: 'DELETE'
  })
}

// 根据店铺id查询所有商品
export const getAllGoodsByStoreId = params => {
  return request({
    url: `goodLists`,
    params
  })
}
